import { ApiProperty } from '@nestjs/swagger'

export class ResData<T = any> {
  @ApiProperty({
    description: '响应数据',
    type: 'object',
    additionalProperties: true,
  })
  data?: T

  @ApiProperty({
    description: '响应状态码',
    example: 200,
    type: 'number',
    enum: [200, 401, 500, 0],
  })
  code: number

  @ApiProperty({
    description: '响应消息',
    example: 'success',
    type: 'string',
  })
  message: string

  constructor(code: number, data: T, message = 'success') {
    this.code = code
    this.data = data
    this.message = message
  }
}

export class User {
  @ApiProperty({
    description: '用户名',
    example: 'uni-app',
    type: 'string',
  })
  userName: string

  @ApiProperty({
    description: '用户ID',
    example: 'ft151512135155',
    type: 'string',
  })
  userId: string

  @ApiProperty({
    description: '访问令牌',
    example: 'cc15f1as15d61as1fd5',
    type: 'string',
  })
  accessToken: string

  @ApiProperty({
    description: '刷新令牌',
    example: 'dd1s5d1f51as5df61a5f5d16',
    type: 'string',
  })
  refreshToken: string
}

export class SimpleUser {
  @ApiProperty({
    description: '示例用户名',
    example: '建议 fteam',
    type: 'string',
  })
  userName: string
}

// export
//
// // 创建一个具体的UserResponse类
// export class UserResData extends ResData<User> {
//   @ApiProperty({
//     description: '返回的用户数据',
//     type: User,
//   })
//   data: User
// }
